<template>
	<div class="btn-group">
		<button @click="edit" class="btn btn-white btn-xs btn-info btn-round">
			编辑
		</button>		
	
		<button @click="del" class="btn btn-white btn-xs btn-warning btn-round" style="margin-left: 5px;">
			删除
		</button>
	</div>
</template>

<script>
export default{
	name: 'operation',
	props: {
		role: Object
	},
	methods: {
		edit() {
				this.$parent.role = $.extend({}, this.role)
				this.$parent.role.password = null
				$('#save-modal').modal('show')
		},
		editPassword() {
				this.$parent.role = $.extend({}, this.role)
				this.$parent.role.password = ''
				$('#editPassword-modal').modal('show')
		},
		del() {
			this.$confirm({title: ' ', content: '确定删除角色: ' + this.role.name + '?'})
				.then(() => {
					let url = process.env.VUE_APP_SERVER + 'system/admin/role/delete/' + this.role.id
					this.$axios.delete(url)
						.then(res => {
							if(res.data.status === 1) {
								this.$toast('已删除角色:' + this.role.name, this.$global.toast.success)
								this.$parent.list(1)
							}else {
								this.$toast(res.data.msg, this.$global.toast.fail)
							}
						})
				})
				.catch(() => {})
		}
	}
}
</script>

<style>
</style>
